package com.talend.support.dashboard.beans;

import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import org.primefaces.model.chart.CartesianChartModel;
import org.primefaces.model.chart.LineChartSeries;

@SuppressWarnings("serial")
@ManagedBean
@RequestScoped
public class LinearChart implements Serializable{
   
   private CartesianChartModel linearModel;

   public LinearChart() {
   }

   public CartesianChartModel getLinearModel() {
       return linearModel;
   }

   @PostConstruct
   public void init() {
       linearModel = new CartesianChartModel();

       LineChartSeries open = new LineChartSeries();
       open.setLabel("Opened");

       open.set("6/3", 110);
       open.set("6/10", 132);
       open.set("6/17", 89);
       open.set("6/24", 120);
       open.set("7/1", 100);
       open.set("7/8", 44);
       open.set("7/15", 150);
       open.set("7/22", 25);

       LineChartSeries close = new LineChartSeries();
       close.setLabel("Closed");
       close.setMarkerStyle("diamond");

       close.set("6/3", 52);
       close.set("6/10", 103);
       close.set("6/17", 62);
       close.set("6/24", 52);
       close.set("7/1", 60);
       close.set("7/8", 110);
       close.set("7/15", 135);
       close.set("7/22", 120);

       linearModel.addSeries(open);
       linearModel.addSeries(close);
   }
}